<html>
<head prefix="og: http://ogp.me/ns#">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">	
<meta property="og:title" content="Khai trương GameToy Shop Nhận quà miễn phí"/>
<meta property="og:site_name" content="GameToy shop" />
<meta property="og:image" content="https://dochoigame.com/faceApp/images/logo4.jpg" />
<meta property="og:image:width" content="200">
<meta property="og:image:height" content="200">

<title>Mừng GameToy khai trương nhận quà hấp dẫn</title>
<div id="fb-root"></div>

<script src="https://connect.facebook.net/vi_VN/all.js"></script>
<script src="jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

<style>
table {
    border-collapse: collapse;
}


</style>

</head>
<script>

 var uId=null;
 var email=null;
 var first_name = null;
 var last_name = null;
 var link = null;
  window.fbAsyncInit = function() 
 {
// init the FB JS SDK #xfbml=1&status=0
	console.log('init function');
    FB.init({
      appId      : '741899475885533', // App ID from the App Dashboard
//      channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
      status     : true, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true  // parse XFBML tags on this page?
    });
     FB.getLoginStatus(function(response)
    {
        console.log("HELLO WORLD");

        if (response.status === 'connected') 
        {
            console.log('login here');
            //ridrect
            
            FB.api(
				    "/me",
				    function (response)
				    {
				      console.log(response);
				      if (response && !response.error) 
					  {
						uId = response.id;
						email = response.email;
						first_name = response.first_name;
						last_name = response.last_name;
						link = response.link;
						console.log("uID = %s Email = %s,first_name = %s,last_name = %s,link = %s",uId,email,first_name,last_name,link);
						  // var m = response.id;
						  // uId = response.id;
						  // email = response.email
						  
				      }
				    }
				  );
            
           		 
//             console.log("end redirect");
        } else if (response.status === 'not_authorized') 
        {
            console.log('not_authorized');  
			var b = 0;
			Login();
			
			
        } else 
        {
            console.log('need login');
            Login();
             // the user isn't logged in to Facebook.
        }
    } );
 }

 function Login()
 {
     FB.login(function(response) {
         if (response.authResponse) 
         {
			console.log("xac thuc thanh cong");
			window.location = "https://dochoigame.com/faceApp/";
            return 1;
         }
         else
             return 0;
    // handle the response
     }, {scope: 'email,public_profile'});
  }
function checkInp()
{
	  var x =null;
	  x = document.getElementById("txtLuckyNum").value;
	  console.log("x = %s",x);
	  
	  if (isNaN(x) || x.length !=3) 
	  {
		alert("Vui lòng nhập 3 số may mắn.");
		return false;
	  }
	  return true;
}
 function ShareDlg()
 {
	var bNumber = checkInp();
	if(!bNumber)
	{
		console.log("KHONG PHAI NUMBER");
		return;
	}
		FB.ui(
		  {
			method: 'share',
			href: 'https://www.facebook.com/GameToyShop/photos/a.665641723553895.1073741829.661564593961608/684030871714980/?type=1',
		  },
		  function(response) {
			if (response && !response.error_code) {
				//alert('Posting completed.'); //ajax post to save data here
				var luckyNumber = document.getElementById("txtLuckyNum").value;
				console.log("LUCKY :%s <br>",luckyNumber);
				var postData = {
						        "uId" : uId,
								"email" : email,
								"first_name" : first_name,
								"last_name" : last_name,
								"link" : link,
								"luckyNumber" : luckyNumber,
						    };
				console.log("post data");
				console.log(postData);
				$.ajax({
					type: "POST",
					url: "getgilf.php",
					data: postData,
					cache: false,
					success: function(result)
					{
						console.log("success RESULT : "+result);
						
						//alert(result);
						if(result == 'RESULT_EXITS')
						{
							console.log("da ton tai UID nay");
							window.location = "https://dochoigame.com/faceApp/gilffail.php";
						}
						if(result == 'RESULT_INSERT_SUCCESS')
						{
							window.location = "gilfok.php";
							console.log("insert successful");
						}
					}
				
				});
			} else {
			  alert('Vui lòng chia sẻ để nhận quà..');
			}
		  }
		);
 }
</script>
<body>
	<h1 align="center"><font color="#FF0000">KHAI TRƯƠNG NHẬN QUÀ</font></h1>

	<h3 align="center"><font color="#009900">CHỌN BA SỐ MAY MẮN <br>KẾT QUẢ ĐỐI CHIẾU VỚI 3 SỐ CUỐI ĐỘC ĐẮC<br>KQXS THỪA THIÊN HUẾ NGÀY THỨ 2 (19/1/2015) </font></h3>
	
	<h3 align="center"><font color="#FF0000"> 1-NH&#7852;P 3 S&#7888; MAY M&#7854;N | </font>
	<font color="#009999"> 2-LIKE PAGE</font><font color="#00FF00"> </font><font color="#FF0000"> 
	| </font><font color="#0066FF"> 3-CHIA S&#7866; </font><font color="#FF0000"> <br> 
	</font><font color="#6600FF"> T&#7914; TH&#7912; 4 - CH&#7910; NH&#7852;T HÀNG TU&#7846;N - T&#7888;I TH&#7912; 2 CÔNG B&#7888; 
	K&#7870;T QU&#7842;</h3>


<table align="center" border="0" width="500" cellspacing="0" background="images/background.jpg">
	
	<tr width="500" height="200" colspan="3">
		<td colspan="3"><img src="images/top.jpg">  </td>
	</tr>
	
	<tr width="500" height="60">
		<td width="166" > <img src="images/leftButton.jpg"> </td>
		<td b>
			<form>
				<br>
				<input id="txtLuckyNum" size='20' style="height: 30px" align='center' type="text" name="luckynumber">
			</form>
		</td>
		<td>  </td>


	</tr>
	
	<tr width="500" height="60">
		<td width="200" align="right">
			<iframe src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FGameToyShop&amp;width=100&amp;layout=button_count&amp;action=like&amp;show_faces=false&amp;share=false&amp;height=21&amp;appId=741899475885533" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
		</td>
		<td width="200" height="60"> 
			<img src="images/shareButton.jpg" alt="Chia sẻ bạn bè" onclick="ShareDlg()">
&nbsp;</td>
		<td>  </td>

	</tr>
	
	<tr width="500" height="50">		
			<td colspan="3" align="center"> <a target="_blank" href="https://www.facebook.com/GameToyShop">VÀO GAMETOY SHOP NHẬN QUÀ THẢ GA</a> </td>


	</tr>
</table>
	<p align="center"><span style="background-color: #99FF99"><font color="#6600FF">
	<b>L&#432;u ý: &#272;ã LIKE thì không b&#7887; LIKE ch&#7881; c&#7847;n CHIA S&#7866;</b></font><font color="#6600FF">
	</font></span></p>
	
	<p align="center"><span style="background-color: #99FF99"><font color="#6600FF">
	<b>L&#432;u ý: Nếu không chia sẻ được vui lòng nhấn F5</b></font><font color="#6600FF">
	</font></span></p>

<table border="1" width="500" align="center" >
	<tr>
		<td>
			<br>
			<h4 align="left"> &nbsp;&nbsp; GI&#7842;I NH&#7844;T : 1.000.000 VND </h4>
			<h4 align="left"> &nbsp;&nbsp; GI&#7842;I NHÌ : Ph&#7847;n quà t&#7921; ch&#7885;n trong SHOP tr&#7883; giá 300.000 VND</h4>
			<h4 align="left"> &nbsp;&nbsp; GI&#7842;I BA :  Ph&#7847;n quà t&#7921; ch&#7885;n trong SHOP tr&#7883; giá 200.000</h4>
			<h4 align="left"> &nbsp;&nbsp; GI&#7842;I T&#431; :  Ph&#7847;n quà t&#7921; ch&#7885;n trong SHOP tr&#7883; giá 100.000</h4>
			<br>
		</td>
	</tr>
</table>


</body>

</html>